const kXMPP_CONTRACTID = "@mozilla.org/XmppListener;1"
const kXMPP_CID = Components.ID("8abf9999-7546-4add-83a3-7dbd30df5541");
const nsISupports = Components.interfaces.nsISupports;

function nsXmppListener()
{
}

nsXmppListener.prototype.QueryInterface = function(iid) {
  if (!iid.equals(Components.interfaces.nsIXmppListener) &&
      !iid.equals(Components.interfaces.nsIXmppService) &&
      !iid.equals(nsISupports))
    throw Components.results.NS_ERROR_NO_INTERFACE;
  return this;
}

/**
 * JS XPCOM component registration goop:
 *
 * We set ourselves up to observe the xpcom-startup category.  This provides
 * us with a starting point.
 */

var nsXmppListenerModule = new Object();

nsXmppListenerModule.registerSelf =
function (compMgr, fileSpec, location, type)
{
  dump ("\n Registering  nsXmppListener ... ");
  compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
  compMgr.registerFactoryLocation(kXMPP_CID,
                                  "nsXmppListener",
                                  kXMPP_CONTRACTID,
                                  fileSpec, 
                                  location, 
                                  type);
  dump ("ok \n ");
}

nsXmppListenerModule.getClassObject =
function (compMgr, cid, iid)
{
  if (!cid.equals(kXMPP_CID))
    throw Components.results.NS_ERROR_NO_INTERFACE;

  if (!iid.equals(Components.interfaces.nsIFactory))
    throw Components.results.NS_ERROR_NOT_IMPLEMENTED;

  return nsXmppListenerFactory;
}

nsXmppListenerModule.canUnload =
function (compMgr)
{
  return true;
}

var nsXmppListenerFactory = new Object();

nsXmppListenerFactory.createInstance = function (outer, iid)
{
  if (outer != null)
    throw Components.results.NS_ERROR_NO_AGGREGATION;

  if (!iid.equals(Components.interfaces.nsIXmppListener) &&
      !iid.equals(nsISupports))
    throw Components.results.NS_ERROR_NO_INTERFACE;

  return new nsXmppListener();
}

function NSGetModule(compMgr, fileSpec)
{
  return nsXmppListenerModule;
}
